package com.example.consumer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author wangjinlong
 * @date 2022/1/26 14:43
 */
@RestController
@RequestMapping("myrest/consumer")
public class ConsumerController {
    private static final String REST_URL = "http://nacos-provider/myrest/provider/get";

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("get")
    public String get(){
        String object = restTemplate.getForObject(REST_URL, String.class);
        System.out.println(object);
        return "hello I'm consumer." + object;
    }
}
